<template>
    <div class="search">
        <el-input
                prefix-icon="el-icon-search"
                placeholder="请输入内容"
                v-model="keywords"
                clearable>
        </el-input>
        <ul class="mui-table-view" v-for='(item,i) in search(keywords)' :key="item.recid">
            <li class="mui-table-view-cell">
                <router-link :to="{path:'/home/yhinfo:id',query:{id:item.recid}}" class="mui-navigate-right">
                    <!--<span class="company">{{item.company}}</span>  -->
                    <!--<span class='fonts'>{{item.sbqk}}</span>-->
                    <span class="company">{{item.yhName}}</span>
                    <!--0:未上报1:已上报待审批2:审定通过3:驳回4:取回-->
                    <span class='fonts'>{{getReportStatus(item.reportingStatus)}}</span>
                </router-link>
            </li>
        </ul>
    </div>
</template>

<script>
    import {Toast} from 'mint-ui'

    export default {
        data() {
            return {
                keywords: '',
            }
        },
        created() {
            this.ifLogin();
        },
        watch: {},
        mounted() {

        },
        methods: {
            ifLogin() {
                if (this.$store.state.loginFlag === false) {
                    Toast("请先登录...");
                }
            },
            search(keywords) {
                return this.$store.state.resultList.filter(item => {
                    // if(item.name.indexOf(keywords) != -1)
                    // 注意 在 ES6中，为字符串提供了一个新方法，叫做  String.prototype.includes('要包含的字符名称')
                    //  如果包含，则返回 true ，否则返回 false
                    //  contain
                    if (item.yhName.includes(keywords)) {
                        return item
                    }
                })
            },
            getReportStatus(statusCode) {
                switch (statusCode) {
                    case 0:
                        return "未上报";
                        break;
                    case 1:
                        return "已上报待审批";
                        break;
                    case 2:
                        return "审定通过";
                        break;
                    case 3:
                        return "驳回";
                        break;
                    case 4:
                        return "取回";
                        break;
                    default:
                        return "未上报";
                        break;
                }
            },
        },
    }

</script>

<style lang="scss">
    .search {
        .el-input__icon {
            height: 70%;
        }
        .fonts {
            font-size: 14px;
            color: #226aff;
            /* display: flex;
            justify-content:space-between; */
            float: right;
            margin-right: 10%;
        }
        .company {
            font-size: 16px;
            color: #030303;
        }

    }
</style>